package 寒假作业.LeetCode;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;

public class Num155 {
    class MinStack{
        Deque<Integer> minStack;
        Deque<Integer> auxiliaryStack;
        public MinStack() {
            auxiliaryStack = new LinkedList<Integer>();
            minStack = new LinkedList<Integer>();
            minStack.push(Integer.MAX_VALUE);
        }
        public void push(int val) {
            auxiliaryStack.push(val);
            minStack.push(Math.min(minStack.peek(),val));
        }
        public void pop() {
            auxiliaryStack.pop();
            minStack.pop();
        }
        public int top() {
            return auxiliaryStack.peek();
        }
        public int getMin() {
            return minStack.peek();
        }
    }


}
